import { FormRules } from 'element-plus'

/**
 * 表格列定义
 */
export const columns = [
  {
    label: '案例描述',
    prop: 'description',
    minWidth: 200
  },
  {
    label: '类型',
    prop: 'type',
    minWidth: 100
  },
  {
    label: '难度',
    prop: 'difficulty',
    minWidth: 100
  },
  {
    label: '状态',
    prop: 'status',
    minWidth: 100
  },
  {
    label: '创建时间',
    prop: 'createTime',
    minWidth: 150
  },
  {
    label: '操作',
    fixed: 'right',
    width: 200
  }
]

/**
 * 表单验证规则
 */
export const formRules: FormRules = {
  name: [
    { required: true, message: '请输入案例名称', trigger: 'blur' },
    { min: 2, max: 50, message: '长度在 2 到 50 个字符', trigger: 'blur' }
  ],
  description: [
    { required: false, message: '请输入案例描述', trigger: 'blur' },
    { min: 0, max: 500, message: '长度不超过500个字符', trigger: 'blur' }
  ],
  type: [
    { required: true, message: '请选择案例类型', trigger: 'change' }
  ],
  difficulty: [
    { required: true, message: '请选择案例难度', trigger: 'change' }
  ]
}

/**
 * 获取案例状态样式
 */
export const getCaseStatus = (status: number) => {
  switch (status) {
    case 0:
      return 'info'
    case 1:
      return 'warning'
    case 2:
      return 'success'
    case 3:
      return 'danger'
    case 4:
      return 'info'
    default:
      return 'info'
  }
}

/**
 * 获取案例难度样式
 */
export const getCaseDifficulty = (difficulty: number) => {
  switch (difficulty) {
    case 1:
      return 'success'
    case 2:
      return 'warning'
    case 3:
      return 'danger'
    default:
      return 'info'
  }
} 